import React, { Component } from 'react'
import Field from './sub/Field'

export default class App extends Component {
    state = {
        username: localStorage.getItem('username'),
        password: "",
    }
    render() {
        return (
            <div>
                <h2>登录页面</h2>

                <Field label="用户名:" type="text" value={this.state.username} onChangeEvt={(value) => {
                    this.setState({ username: value })
                }} />
                <Field label="密码:" type="password" value={this.state.password} onChangeEvt={(value) => {
                    this.setState({ password: value })
                }} />

                <button onClick={() => {
                    console.log(this.state.username, this.state.password, "发送到服务端")
                }}>登录</button>
                <button onClick={() => {
                    this.setState({
                        username: "",
                        password: ""
                    })
                }}>取消</button>
            </div>
        )
    }
}
